#include <stdio.h>
#include "io_button.h"

/*绑定设备驱动*/
struct device_button_io_i device_button_io = {
    .io_init = (device_button_io_init_fn_t)device_button_io_init,
    .io_get = (device_button_io_get_fn_t)device_button_io_get,
};

/*绑定外调接口*/
struct button_i interface = {
    .get_num   = (button_get_num_fn_t)bl_button_get_num,
};

/*初始化*/
int bl_button_init(struct bl_button *self)
{
    self->io_interface = &device_button_io;
    self->interface = &interface;
    self->io_interface->io_init();
    self->but_num = 0;
    self->state = 0;
    return 0;
}

int bl_button_get_num(struct bl_button *self)
{
    self->but_num = self->io_interface->io_get();
    return self->but_num;

}
